﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Windows.Controls.DataVisualization;
using System.Windows.Data;

namespace QSDesigner
{
    public class GraphicsColorConverter: IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var colorList = parameter as ResourceDictionaryCollection;
            /*var str = value.ToString();
            var number = str.Substring(0, str.Length - " канал(а/ов)".Length);*/
            var number = ((string) value).TakeWhile(str => !str.Equals(' ')).First().ToString();
            var idx = Int32.Parse(number);
            //var idx = (int) value;
            return colorList[idx % colorList.Count]["Background"];
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
